package com.cskaoyan.config3;

import com.alibaba.druid.pool.DruidDataSource;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * @author stone
 * @date 2022/06/24 15:13
 */
@Configuration
@Data // 主要是为了提供set方法
@ConfigurationProperties(prefix = "cskaoyan.datasource")
public class DataSourceConfiguration3 {

    //cskaoyan.datasource.driverClass
    String driverClass;
    //cskaoyan.datasource.url
    String url;
    //cskaoyan.datasource.username
    String username;
    //cskaoyan.datasource.password
    String password;


    @Bean
    public DataSource dataSource3() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(driverClass);
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return dataSource;
    }
}
